from flask import Blueprint
from flask import redirect
from flask import request
from flask import session

admin_blue = Blueprint("admin",__name__,url_prefix="/admin")

from . import views


@admin_blue.before_request
def check_admin():
    # 获取session里面的数据
    is_admin = session.get("is_admin",False)
    # 如果不是管理员,就不能进入到后台系统,并且,也不能让他请求后台的url地址
    if not is_admin and not request.url.endswith("/admin/login"):
        return redirect("/")